package com.sand.entity;

import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Objects;

@Entity
@Table(name = "message", schema = "ssh_pro", catalog = "")
public class MessageEntity {
    /**
     * @author <achao1441470436@gmail.com>
     * @since 2021/11/28/028 14:46
     */
    private int rid;
    private int userId;
    private int landlordId;
    private Timestamp lastChatTime;
    private String lastChatMessage;

    @Id
    @GeneratedValue(generator = "message")
    @GenericGenerator(name = "message", strategy = "native")
    @Column(name = "rid")
    public int getRid() {
        return rid;
    }

    public void setRid(int rid) {
        this.rid = rid;
    }

    @Basic
    @Column(name = "userId")
    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    @Basic
    @Column(name = "landlordId")
    public int getLandlordId() {
        return landlordId;
    }

    public void setLandlordId(int landlordId) {
        this.landlordId = landlordId;
    }

    @Basic
    @Column(name = "lastChatTime")
    public Timestamp getLastChatTime() {
        return lastChatTime;
    }

    public void setLastChatTime(Timestamp lastChatTime) {
        this.lastChatTime = lastChatTime;
    }

    @Basic
    @Column(name = "lastChatMessage")
    public String getLastChatMessage() {
        return lastChatMessage;
    }

    public void setLastChatMessage(String lastChatMessage) {
        this.lastChatMessage = lastChatMessage;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        MessageEntity that = (MessageEntity) o;
        return rid == that.rid && userId == that.userId && landlordId == that.landlordId && Objects.equals(lastChatTime, that.lastChatTime) && Objects.equals(lastChatMessage, that.lastChatMessage);
    }

    @Override
    public int hashCode() {
        return Objects.hash(rid, userId, landlordId, lastChatTime, lastChatMessage);
    }
}
